From dfc0eb692348282a36d31a0284614e0066dfe0f4 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 10 Feb 2025 15:07:05 +0800 Subject: [PATCH] gui/macOS: Fix accountIdFromDomainId Signed-off-by: Claudio Cambra --- src/gui/macOS/fileproviderdomainmanager_mac.mm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/macOS/fileproviderdomainmanager_mac.mm b/src/gui/macOS/fileproviderdomainmanager_mac.mm index d1660810a..1c033554d 100644 --- a/src/gui/macOS/fileproviderdomainmanager_mac.mm +++ b/src/gui/macOS/fileproviderdomainmanager_mac.mm @@ -104,7 +104,21 @@ QString accountIdFromDomainId(const QString &domainId) QString accountIdFromDomainId(NSString * const domainId) { - return accountIdFromDomainId(QString::fromNSString(domainId)); + auto qDomainId = QString::fromNSString(domainId); + if (!qDomainId.contains('-')) { + return qDomainId.replace("(.)", "."); + } + // Using slashes as the replacement for illegal chars was unwise and we now have to pay the + // price of doing so... + const auto accounts = OCC::AccountManager::instance()->accounts(); + for (const auto &accountState : accounts) { + const auto account = accountState->account(); + const auto convertedDomainId = domainIdentifierForAccount(account); + if (convertedDomainId == qDomainId) { + return account->userIdAtHostWithPort(); + } + } + Q_UNREACHABLE(); } API_AVAILABLE(macos(11.0)) -- 2.30.2